﻿//XmasSpecial___Apu_Xmas
//Cookie.cs
//By Johanna Carlsson 2012-12-09

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XmasSpecial___Apu_Xmas
{
    /// <summary>
    /// This class handles most of the cookie information
    /// </summary>
    class Cookie : BakeryItem
    {
        private double weight;


        /// <summary>
        /// Constructor with two parameters. calls its base class to set and
        /// get name and price.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="price"></param>
        public Cookie(string name, double price, double grams)
            : base(name, price)
        {
            this.weight = grams;
        }



        /// <summary>
        /// Property related to the field weight, both read and write access
        /// </summary>
        public double Weight
        {
            get
            {
                return weight;
            }
            set
            {
                if (value >= 0.0)
                    weight = value;
            }
        }


        /// <summary>
        ///  property to the field Price. read acces Counts the "totalprice"
        /// </summary>
        public override double Price
        {
            get
            {
                return base.Price * Weight;
            }
        }



        /// <summary>
        /// Adds more info to the base classes string and returns a formatted
        /// string
        /// </summary>
        /// <returns> a formatted string</returns>
        public override string ToString()
        {
            return string.Format("{0}\r\nThese cookies will cost \r\n {1:F2} kr" +
                                    "\r\n\r\nMerry Christmas!",
                                    base.ToString(), this.Price);
        }
    }
}
